<!--
 * @Description: 层次选择器
 * @Author: rendc
 * @Date: 2021-08-05 16:36:39
 * @LastEditors: rendc
 * @LastEditTime: 2021-08-05 16:58:49
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>层次选择器</title>
  <style>
    /* 后代选择器 */
    /* #app p {
      background-color: honeydew;
    } */
    /* 子代选择器 */
    /* #app>p {
      background-color: honeydew;
    } */
    /* 相邻同胞选择器 */
    /* .myP+* {
      background-color: honeydew;
    } */
    /* 一般同胞选择器 */
    .myP~* {
      background-color: honeydew;
    }
  </style>
</head>

<body>
  <div id="app">
    <div class="myDiv" id="one">1</div>
    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
    <div class="myDiv" id="two">2</div>
    <div class="myDiv" id="three">
      <p class="myP">p2-1</p>
      <div>123</div>
      <p class="">p2-2</p>
      <p class="">p2-2</p>
      <p class="">p2-2</p>
      <p>p2-3</p>
      <div>3</div>
      <div>4</div>
      <div>5</div>
    </div>
  </div>
</body>

</html>